Different execution platforms, such as central processing units (CPU), may support different feature sets for software applications. For example, a new version of a CPU may support more advanced features in software applications than an older version. As illustrated in FIGS. 1A and 1B, Intel Pentinum II Processor does not support the more advanced SSE instructions of the Intel Pentium III Processor. Applications may be written to include functions that take advantage of advanced features in newer execution platforms which makes the applications execute faster. However, these applications may also need to be compatible with older versions of the platforms. To address the need for specific versions of functions in software applications, multiversioned code may be written that contains multiple different versions of a function. Multiversioned code may contain several versions of a function that are semantically identical.
Frequently-executed functions in software applications are sometimes compiled into several different versions to take advantage of specific advanced features present in some hardware versions and to allow the software application to be compatible with older variants of hardware on which the applications are executed. Each version of the function may be written to support and execute on a specific execution platform. This function multiversioning allows for the creation of a single application executable binary that can execute on variants of a specific hardware platform while taking advantage of advanced features that are only available on certain variants of the platform.
It is somewhat difficult to test all versions of a multiversioned function. Running the function once will only exercise a specific version of the function leaving the other function versions untested. This option limits code coverage and lets bugs in versioned functions go undetected.
One simple solution to the testing problem is to let an executable with multiversioned functions run on all possible variants of hardware for which specialized versions were created. However, testing on all physical hardware variations of a platform is simply not feasible or cost-effective. Therefore, platforms are simulated in software to mimic the behavior of hardware variants for platforms.
Simulating the platform solves the problem of code coverage testing. However, this method of testing may introduce a new problem. The multiversioned code may contain some instructions that always get executed, regardless of the platform variation on which the function is run. For instance, a program may execute a piece of code containing advanced instruction without checking for the appropriate run-time support of the executing platform. This unchecked execution may be a bug that simulation simply does not detect. Although these instructions may be supported by some variations of the platform, the instructions may not be supported by all variations of the platform. If a program executes a piece of code containing advanced instructions without checking for the appropriate run-time support on the executing platform, the program will crash on platforms that do not support these advanced features. With simulation, this execution may succeed as the real platform on which the simulation executes may support the advanced features. In other words, the simulated testing does not always identify or detect all versioning errors. As recognized by the inventors, there should be a method of testing multiversioned functions that detects the execution of unsupported instructions on a simulated platform regardless of the functionality of the underlying platform that is executing the test.